var ec_left2 = echarts.init(document.getElementById("l2"), "dark")

$.get('http://localhost:8080/player/list', function (data) {
    var names = []
    var nums = []
    for (var i = 0; i < data.length; i++) {
        names.push(data[i].player);
        nums.push(data[i].scores);
    }

    // 基于准备好的dom，初始化echarts实例

    ec_left2.setOption({
        title: {
            text: 'NBA十佳球员场均得分'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        legend: {
            data: ['场均得分']
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                boundaryGap: false,
                data: names
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: '场均得分',
                type: 'line',
                stack: 'Total',
                areaStyle: {},
                emphasis: {
                    focus: 'series'
                },
                data: nums
            },
        ]
    });
});

